define(function(require,exports,module){
    var $ = require("jquery");
    //验证信息弹出框显示关闭
    $.fn.showErrorMsg = function(){
        $(this).removeClass('fadeOutUp animated').addClass('fadeInDown animated')
        .parent().css({
            'display':'block',
            'zIndex':30
        })
        setTimeout(function(){
            this.removeClass('fadeInDown animated').addClass('fadeOutUp animated');
            setTimeout(function(){
                this.parent().css({
                    'zIndex':-1,
                    'display':'none'
                }).empty();
            }.bind(this),500);
        }.bind(this),2000);
        return this
    };
    //自定义消息内容
    $.extend ({
        showCustomErrorMsg :function(content){
            if($('#errorBox').children().length==0){
                $('<div>').appendTo('#errorBox').addClass('showerror').html(content).showErrorMsg();
            }   
        }
    })
    //模态框显示
    $.fn.showModal = function(mIn,mOut,addModalBg){
        //默认添加一个背景
        var modalin = !mIn?  'fadeInDown':mIn;
        var modalout = !mOut? 'fadeOutUp' :mOut;
        var modalBg = addModalBg==false? addModalBg : true;//是否添加背景
        var cName = this[0].className;
        var wordsPUM = cName.slice(cName.indexOf('popUpModal'));
        this.css({
            'display':'block',
            'zIndex':29
        });
        $('body').css('overflow','hidden');
        if(modalBg){
            $('<div>').appendTo('body').addClass('modal animated fadeIn').click(function(){
            	$(this).closeModal(mIn,mOut);
            }.bind(this));
        }
        //移除除第一个单词以外其他的单词
        this.removeClass(wordsPUM).addClass(' popUpModal animated '+modalin);
    };
    //模态框关闭
    $.fn.closeModal=function(mIn,mOut,bgClose){
        //默认全部背景关闭
        var modalin = !mIn?  'fadeInDown':mIn;
        var modalout = !mOut? 'fadeOutUp' :mOut;
        var mBgClose = bgClose==false? bgClose :true;//是否关闭背景
        var cName = this[0].className;
        var wordsPUM = cName.slice(cName.indexOf('popUpModal'));
        //移除除第一个单词以外其他的单词
        this.removeClass(wordsPUM).addClass(' popUpModal animated '+modalout);
        if(mBgClose){
            $('div.modal').unbind().removeClass('fadeIn').addClass('fadeOut');
        }
        $('body').css('overflow','auto');
        setTimeout(function(){
            this.css({
                'zIndex':-1,
                'display':'none'
            });
            if(mBgClose){
                $('div.modal').remove();
            }
        }.bind(this),500);
    };
})
